package com.hezhiqin.formework.aop.aspect;

import com.hezhiqin.formework.aop.intercept.HZQMethodInterceptor;
import com.hezhiqin.formework.aop.intercept.HZQMethodInvocation;

import java.lang.reflect.Method;

/**
 * @program: homeWork
 * @description:
 * @author: hezhiqin
 * @create: 2019-11-06 16:00
 */
public class HZQAfterThrowingAdviceInterceptor extends HZQAbstractAspectAdvice implements HZQMethodInterceptor {


    private String throwName;

    public HZQAfterThrowingAdviceInterceptor(Method aspectMethod, Object aspectTarget) {
        super(aspectMethod, aspectTarget);
    }

    public void setThrowName(String throwName) {
        this.throwName = throwName;
    }

    @Override
    public Object invoke(HZQMethodInvocation invocation) throws Throwable {
        try {
            return invocation.proceed();
        }catch (Throwable e){
            invokeAdviceMethod(invocation,null,e.getCause());
            throw e;
        }
    }
}
